package com.ceshiren.hogwarts.framework;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.HashMap;
import java.util.List;

public class TestCase {
    private WebDriver webDriver;
    public List<String> data;
    public List<HashMap<String,Object>> steps;
    protected By by;
    public  void run(){
        /*if (data.size()>0){
            data.forEach(d->{

            });
        }*/
        steps.forEach(step->{
            if (step.containsKey("chrome")){
                webDriver = new ChromeDriver();
            }
            if (step.containsKey("get")){
                webDriver.get(step.get("get").toString());
            }
            if (step.containsKey("find")){
                by = By.id(step.get("find").toString());
            }
            if (step.containsKey("click")){
                webDriver.findElement(by).click();
            }
            if (step.containsKey("sendkeys") && data.size()>0){
                webDriver.findElement(by).sendKeys(data.get(0));
            }
        });
    }

}
